package com.kc.sjwh.service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.kc.sjwh.other.Cfg;

/**
 * 启动（或关闭）服务时可执行的内容
 * date: 2017年5月17日
 * @author zhangGuihua(hua7381@163.com)
 */
@Service
public class StartServer {
	static Logger logger = Logger.getLogger(StartServer.class);
	
	@Autowired
	SysService sysService;
	
	@PostConstruct
	public void fn1() {
		logger.info("启动中...");
		
		//加载动态配置项
		logger.info("加载配置参数");
		Cfg.getInst().load();
		logger.info(JSON.toJSONString(Cfg.getInst()));
		
		//加载字典
		logger.info("加载字典");
		try {
			sysService.loadDict();
		} catch (Exception e) {
			logger.error("加载字典发生错误", e);
		}
		
		logger.info("启动成功.");
	}
	
	@PreDestroy
	public void fn2() {
		logger.info("关闭中...");
		logger.info("关闭成功");
	}
}
